//
//  LGGraveyarChildDetailViewController.m
//  ligenyun
//
//  Created by Mac on 2018/4/9.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "LGGraveyarChildDetailViewController.h"

@interface LGGraveyarChildDetailViewController ()
@property(nonatomic, strong) NSArray     *dataSouce;
@end

@implementation LGGraveyarChildDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configSubView];
    self.tableView.contentInset = UIEdgeInsetsZero;
    self.tableView.frame = CGRectMake(0, 0, UIScreenWidth, [TMUtils tabBarTop] - [TMUtils navgationBarBootom]);
    [self configFooterAndBottomView];
    [self configDataSouce];
    // Do any additional setup after loading the view.
}

#pragma mark --SubView
- (void)configSubView{
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 40)];
    header.backgroundColor = [UIColor whiteColor];
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth,150)];
    imageView.userInteractionEnabled = YES;
    imageView.image = [UIImage imageNamed:@"组9"];
    [header addSubview:imageView];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(15,imageView.bottom, 200, 20)
                                                    text:@"朝阳墓园"
                                               textColor:FirstTextColor
                                                    font:15
                                             isSizetoFit:NO
                                           textAlignment:NSTextAlignmentLeft];
    [header addSubview:titleLable];
    
    STLabel * addLable = [[STLabel alloc] initWithFrame:CGRectMake(15,titleLable.bottom, UIScreenWidth - 30, 20)
                                                    text:@"北京海定区五道口1897号"
                                               textColor:SecendTextColor
                                                    font:13
                                             isSizetoFit:NO
                                           textAlignment:NSTextAlignmentLeft];
    [header addSubview:addLable];
    
    STLabel * moneyLable = [[STLabel alloc] initWithFrame:CGRectMake(15,addLable.bottom, UIScreenWidth - 30, 20)
                                                   text:@"￥123"
                                              textColor:TM_redColor
                                                   font:13
                                            isSizetoFit:NO
                                          textAlignment:NSTextAlignmentLeft];
    [header addSubview:moneyLable];
    __weak typeof(self) weakSelf = self;
    STButton * arButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, 80, 44)
                                                      title:@"AR全景图"
                                                 titleColor:SecendTextColor
                                                  titleFont:15
                                               cornerRadius:0
                                            backgroundColor:nil
                                            backgroundImage:nil
                                                      image:nil];
    arButton.right = UIScreenWidth - 15;
    arButton.centerY = moneyLable.centerY;
    [arButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelctedArButton];
    }];
    [header addSubview:arButton];
    
    
    UIView * grawView1 = [[UIView alloc] initWithFrame:CGRectMake(0, arButton.bottom + 5, UIScreenWidth, 10)];
    grawView1.backgroundColor = self.tableView.backgroundColor;
    [header addSubview:grawView1];
    
    STLabel * activityLable = [[STLabel alloc] initWithFrame:CGRectMake(15,grawView1.bottom, UIScreenWidth - 30, 44)
                                                    text:@"活动公告，公元前继续享受95折"
                                               textColor:SecendTextColor
                                                    font:15
                                             isSizetoFit:NO
                                           textAlignment:NSTextAlignmentLeft];
    [header addSubview:activityLable];
    
    UIView * grawView2 = [[UIView alloc] initWithFrame:CGRectMake(0, activityLable.bottom , UIScreenWidth, 10)];
    grawView2.backgroundColor = self.tableView.backgroundColor;
    [header addSubview:grawView2];
    
    UIView * sectionHeader = [TMUtils headerViewWithTitle:@"基本信息"];
    sectionHeader.top = grawView2.bottom;
    sectionHeader.backgroundColor = [UIColor whiteColor];
    [header addSubview:sectionHeader];
    header.height = sectionHeader.bottom;
    self.tableView.tableHeaderView = header;
    
    
}
- (void)configFooterAndBottomView{
    UIView * footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 49)];
    self.tableView.tableFooterView = footer;
    __weak typeof(self) weakSelf =  self;
    UIView * bootomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 49)];
    bootomView.bottom = self.tableView.bottom;
    bootomView.backgroundColor = [UIColor whiteColor];
    [bootomView st_showTopShadow];
    STButton * buyButton = [[STButton alloc] initWithFrame:CGRectMake(0, 1, 100, 48)
                                                     title:@"立即咨询"
                                                titleColor:[UIColor whiteColor]
                                                 titleFont:18
                                              cornerRadius:0
                                           backgroundColor:TM_redColor
                                           backgroundImage:nil
                                                     image:nil];
    buyButton.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    buyButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    buyButton.right = UIScreenWidth;
    [bootomView addSubview:buyButton];
    [buyButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelectedCommunicateButton];
    }];
    
    STLabel * phoneLable = [[STLabel alloc] initWithFrame:CGRectMake(15,0, buyButton.left - 30, 44)
                                                     text:@"联系电话:18380461889"
                                               textColor:FirstTextColor
                                                    font:15
                                             isSizetoFit:NO
                                           textAlignment:NSTextAlignmentLeft];
    [bootomView addSubview:phoneLable];
    [self.view addSubview:bootomView];
}
- (void)configDataSouce{
    NSArray * array1 = @[
                         [[STTableEasyModel alloc] initWithTextString:@"陵园名称:" detailString:@"八宝山"],
                         [[STTableEasyModel alloc] initWithTextString:@"零元级别:" detailString:@"特技"],
                         [[STTableEasyModel alloc] initWithTextString:@"陵园规模:" detailString:@"2000做"],
                         [[STTableEasyModel alloc] initWithTextString:@"创建时间" detailString:@"2018年04月09日22:21:05"],
                         [[STTableEasyModel alloc] initWithTextString:@"陵园名人" detailString:@"周恩来"]
                         ];
    NSArray * array2 = @[
                         [[STTableEasyModel alloc] initWithTextString:@"陵园性质:" detailString:@"经营"],
                         [[STTableEasyModel alloc] initWithTextString:@"公交路线:" detailString:@"1路"],
                         [[STTableEasyModel alloc] initWithTextString:@"在售墓型:" detailString:@"商品墓  草坪墓  基督教墓"]
                         ];
    self.dataSouce = @[array1,array2];
    [self.tableView reloadData];
}
#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.dataSouce.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return [self.dataSouce[section] count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 0.01;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
        
    }
    STTableEasyModel * model = self.dataSouce[indexPath.section][indexPath.row];
    [cell setSt_tableEasyModel:model];
    cell.accessoryType = UITableViewCellAccessoryNone;
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}

#pragma mark --Action Method
- (void)onSelctedArButton{
    
}
- (void)onSelectedCommunicateButton{
    
}
@end
